package com.tonyodev.fetchapp.fetch2core;

import ohos.aafwk.ability.DataAbilityRemoteException;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.app.Context;
import ohos.app.Environment;

import com.tonyodev.fetch2core.StorageResolverHelper;

import org.junit.Before;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class StorageResolverHelperTest {
    private Context context;
    private String filePath;

    @Before
    public void setUp() throws Exception {
        context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        filePath = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).toString() + "/" + "test.txt";
    }

    @Test
    public void getHelper() {
    }

    @Test
    public void deleteFile() {
        try {
            createFileAtPath();
            boolean isDelete = StorageResolverHelper.deleteFile(filePath, context);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void renameFile() {
        try {
            createFileAtPath();
            StorageResolverHelper.renameFile("", "", context);
        } catch (DataAbilityRemoteException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void createFileAtPath() {
        try {
            StorageResolverHelper.createFileAtPath(filePath, false, context);
        } catch (DataAbilityRemoteException | IOException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void createLocalFile() {
    }
}